package inventory.daoImplementer;

import java.sql.SQLException;

import dbhandelling.Crude;
import dto.IssueSlip;
import inventory.daoInterface.IssueSlipDao;
import inventory.daoInterface.IssueSlipDao;

public class IssueSlipImplementor extends Crude implements IssueSlipDao
{
	
	@Override
	public void add(IssueSlip issueSlip) throws Exception 
	{
		insert(issueSlip);
	}

	@Override
	public void update(IssueSlip issueSlip) throws Exception 
	{
		super.update("IssueSlip","status" ,issueSlip.getStatus()+"", "issueSlipNo",issueSlip.getIssueNo()+"");
	}

	@Override
	public void delete(IssueSlip issueSlip) throws Exception 
	{
		super.delete("IssueSlip","issueSlipNo",issueSlip.getIssueNo()+"");
	}

	@Override
	public IssueSlip retreive(String conditionField, String ConditionValue) throws Exception 
	{
		IssueSlip issueSlip=(IssueSlip) super.retreive("IssueSlip",conditionField, ConditionValue);
		return issueSlip;
	}

	@Override
	public IssueSlip[] retreiveArray(String conditionField, String conditionValue) throws Exception 
	{
		IssueSlip[] issueSlips;
		Object[] obj=super.retreiveArrayOnCondition("IssueSlip", conditionField, conditionValue);
		issueSlips=new IssueSlip[obj.length];
		
		for(int i=0;i<issueSlips.length;i++)
		{
			issueSlips[i]=(IssueSlip) obj[i];
		}
		
		return issueSlips;
	}

	@Override
	public IssueSlip[] retreiveAll() throws Exception 
	{
		IssueSlip[] issueSlips;
		
		Object[] obj=super.retreiveAll("IssueSlip");
		
		issueSlips=new IssueSlip[obj.length];
		
		for(int i=0;i<issueSlips.length;i++)
		{
			issueSlips[i]=(IssueSlip) obj[i];
		}
		
		return issueSlips;
	}

}
